﻿using QuocHoi_TV_Frontend.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcPaging;
namespace QuocHoi_TV_Frontend.Controllers
{
    public class CategoriesController : MenuController
    {
        //
        // GET: /Categories/

        public ActionResult CategoriesHome(long CategoryId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value : 1;
            ViewBag.CategoryId = CategoryId;

            Category objCate = DataModels.SelectOne(CategoryId);
            ViewBag.objCate = objCate;
            
            ViewBag.lstcatenews = DataModels.GetNewsByCate(CategoryId, 1);
            List<News> lstnews = DataModels.GetNewsByCate(CategoryId, 1000);          

            //var list = 
            if (Request.IsAjaxRequest())
                return PartialView("_ListNewsCategories", lstnews.ToPagedList(currentPageIndex, 12));
            else
                return View(lstnews.ToPagedList(currentPageIndex, 12)); 
            
        }
      
    }
}
